
package cn.net.greenet.user.operation;

import cn.net.greenet.common.db_service.BaseDao;

/**
 * 用户操作策略（创建、编辑和删除）
 *
 * @author liangdelin
 */
public class UserPolicyAction {

    /*
     创建策略日志
     */
    public static void createPolicy(String username, String instance, long messageSerailNo, String messageType) {
        try {
            BaseDao baseDao = new BaseDao();
            int row = baseDao.executeUpdate("INSERT INTO useroperation(username,operation_time,`describe`) VALUES(?,?,?)", new Object[]{username, System.currentTimeMillis(), "用户" + username + "在策略类型为：" + messageType + "的" + instance + "策略仓库下创建策略，现在版本号变更为：" + messageSerailNo});
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /*
     编辑策略日志
     */
    public static void editPolicy(String username, String instance, long messageNo, long messageSerailNo, String messageType) {
        try {
            BaseDao baseDao = new BaseDao();
            int row = baseDao.executeUpdate("INSERT INTO useroperation(username,operation_time,`describe`) VALUES(?,?,?)", new Object[]{username, System.currentTimeMillis(), "用户" + username + "在策略类型为：" + messageType + "的" + instance + "策略仓库下编辑策略MessageNo为:" + messageNo + "策略，现在版本号变更为：" + messageSerailNo});
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void deletePolicy(String username, String instance, long messageNo, long messageSerailNo, String messageType) {
        try {
            BaseDao baseDao = new BaseDao();
            int row = baseDao.executeUpdate("INSERT INTO useroperation(username,operation_time,`describe`) VALUES(?,?,?)", new Object[]{username, System.currentTimeMillis(), "用户" + username + "在策略类型为：" + messageType + "的" + instance + "策略仓库下删除策略MessageNo为:" + messageNo + "策略，现在版本号变更为：" + messageSerailNo});
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
